package com.example.gateway.fallback;

import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;

import java.util.Objects;

/**
 * @Author: 杨雄杰
 * @Date: 2021/5/25 5:57 下午
 */

@RestController
public class FallbackController {

    @RequestMapping("/defaultFallback")
    public String defaultFallback(ServerWebExchange exchange){
        System.out.println("服务降级..."+ Objects.toString(exchange.getAttribute(ServerWebExchangeUtils.HYSTRIX_EXECUTION_EXCEPTION_ATTR)));
        return "{\"msg\":\"熔断降级\",\"code\":200}";
    }

}